
# encodint:utf8

LAN_VAL = dict(
    glan=dict(
        CCPM_DESC="*ccpm* is a tools-chain for manage the cocos like game modules.\
                    same as npm for javascript.",
        CHK_VERSION="chk the ccpm ver...",
        DONE="done!",
        FILE_NOT_FIND="not find the target file->[%s]",
        ERR_RUNCMD="run shell->[%s] raise error!",
        ERR_PLUGININIT="init the plugin raise error!",
        ERR_VER_FRMT="plugin ver must formt like 'vx.x.x'",

    ),
    pmbase=dict(
        ERR_LOCALENV_NOCFG="Not in *plugin* path, Not find *packcfg.json* in the path!",
        INPUT_PLUGIN_NAME="Input the plugin name",
        IGNORE_HOOK_FUNC="if ignore hook func when command running? default is false"
    ),
    publish=dict(
        PARM_M_DESC="package pack mode release|dev? dev \
                                    just for xl",
        IS_ASSET_LIST="genrate asset filelist with md5 desc && luac all file",
        UPLOAD_TAR_TO_OSS2="Not upload file by sftp!Change upload to oss2",
        ERR_REUQIREFMT="not find conf file or file not in wanted fmt",
        ERR_REQUIRE_ENTRYF="not find config entry file ->[%s]",
        ERR_REMOTE_PLUGINEXIST="plugin name<%s@%s> is exist in remote!",
        ERR_DOWNLOAD_FAILED="donwload the plugin failed!->[%s]",
        ERR_GET_GITEEUSR_FAILED="get usr info failed!",
        ERR_GET_DING_FAILED="get usr info failed!",
        ERR_INSERT_DB_FAILED="plugin insert the mysql-db failed!",
        ERR_KEYFMT_DISABLE="plugin fmt check failed!",
        RUN_STEP1="chking the *packcfg.json*...",
        RUN_STEP2="chking the plugin-name in remote...",
        RUN_STEP3="packing plugin...",
        RUN_STEP4="chking the local-usr cache info..."
    ),
    unpublish=dict(
        DESC_DELETE_SUC="dele the plugin<%s> success!",
        ERR_CHK_USER="Get user info failed! Run ccpm cmd<adduser> first!",
        ERR_DELETE_FAILED="dele the plugin<%s> failed!"
    ),
    uploadtool=dict(
        DESC_UPLOAD_TARFILE="the zipfile u want to upload",
        DESC_UPLOAD_TARVER="tool ver string like v1.1.1",
        DESC_UPLOAD_TARNAME="tool name",
        DESC_UPLOAD_TARDESC="tool desc",
        ERR_NOT_MUSTPARAMS="params must full",
        ERR_GET_GITEEUSR_FAILED="get usr info from failed!",
        DESC_UPLOADING_FILE="uploading resource...",
        ERR_UPLOAD_FAILED="upload plugin zip-file to remote failed!",
        ERR_INSERT_DB_FAILED="plugin insert the mysql-db failed!",
    ),
    relconf=dict(

    ),
    adduser=dict(
        ERR_PWDLOGIN_INPUT="must input  <%s>  username and password!",
        PARAMS_AUTHTYPE_DESC="auth support <gitee> and <github>(feature) type",
        PARAMS_USR_DESC="input u <gitee.com> user name",
        PARAMS_PWD_DESC="input u <gitee.com>  password",
    ),
    install=dict(
        ERR_NOPLUGIN_INREMOTE="not find plugin named [%s]",
        ERR_NOSPECIALVER="install plugin <%s> must have ver key words \
                    like $pluginname@@ver",
        ERR_NOPLUGINVER_INREMOTE="not find plugin <%s> verions in remote list-->[%s]",
        ERR_NOVER_APPOINT="not appoint target ver, if u want use newest, ver must be <+>",
        INFO_ALREADY_NEWEXIST="plugin <%s ver:%s> already exist!pass install!",
        INFO_WILL_UPGRADE="plugin <%s ver:%s> will upgrade to <%s ver:%s>!"
    ),
    clean=dict(
        RUN_CLEANSUC="clean the ccpm_plugins install path!",
        ERR_NOTINSTALLED="Not find ccpm plugins installed in the path!"
    ),
    whoami=dict(
        ERR_NOUSRINFO_CACHE="not find userinfo cache in local",
    ),
    initcfg=dict(
        ERR_ALREADY_PACKJSON="config file-> %s is alresty exist!",
        INFO_CRTCONF_SUC="init conf file-> %s in the path success~ \n \
                            edit the value!",
    ),
    upgrade=dict(
        ERR_LOCALENV_CFGFMT="local conf-file-><%s> have wrong fmt",
        INFO_UPGRADE_SUCCESS="upgrade success!",
    ),
    run=dict(
        PARSER_DESC_RUNTYPE="input the run type",
        ERR_NOTE_CONFIG_DEVTOOL="not set script runtype-><%s> to run!",
        ERR_DEVTOOL_NOT_INSTALL_YET="the proj dev-tool not install ready!",
        ERR_NOT_RUNABLE_PATH="the path have not packcfg.json or packcfg.json not 'scripts' val, no run able!"
    )
)


class Lan:
    @staticmethod
    def g(key):
        if key in LAN_VAL["glan"]:
            return LAN_VAL["glan"].get(key)
        return key

    @staticmethod
    def p(pname, key, *argv):
        if pname in LAN_VAL:
            if key in LAN_VAL[pname]:
                return LAN_VAL[pname].get(key) % (argv)
        return "%s_%s" % (pname, key)
